﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using MySql.Data.MySqlClient;


// NOTE: If you change the class name "Service" here, you must also update the reference to "Service" in Web.config and in the associated .svc file.
public class MoodleService : IMoodleService
{
    public string GetData(string value)
    {
        return string.Format("You entered: {0}", value);
    }

    List<Activity> IMoodleService.GetActivityCountByCourse(int courseid)
    {
        /*
         string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["dmc_mysql"].ToString();
        MySqlConnection conn = new MySqlConnection(connectionString);
        MySqlCommand cmd = new MySqlCommand("select count(*) as count,mdl_course.fullname from mdl_log inner join mdl_course on mdl_log.course=mdl_course.id where category=7 group by course",conn);
        MySqlDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
        List<Activity> NF07 = new List<Activity>();
        for (; reader.Read(); )
        {
            NF07.Add(new Activity((string)reader["fullname"],(int)reader["count"]));
        }
        reader.Close();
        return NF07;
         */
        List<Activity> NF07 = new List<Activity>();
        NF07.Add(new Activity("Browse", 500));
        NF07.Add(new Activity("Post", 200));
        NF07.Add(new Activity("Submit Assignment", 300));
        return NF07;
        //throw new NotImplementedException();
    }

}
